package encryption

import "golang.org/x/crypto/bcrypt"

// GetPwd 获得密码
func GetPwd(pwd string) (string, error) {
	password, err := bcrypt.GenerateFromPassword([]byte(pwd), 14)
	return string(password), err
}

// ComparePwd pwd1 是数据库的已经加密的密码， pwd2 是用户实际的密码。
func ComparePwd(pwd1 string, pwd2 string) bool {
	err := bcrypt.CompareHashAndPassword([]byte(pwd1), []byte(pwd2))
	return err == nil
}
